package com.prolificinteractive.materialcalendarview;

import ohos.agp.components.AttrHelper;
import ohos.agp.components.Text;
import ohos.agp.text.Font;
import ohos.agp.utils.Color;
import ohos.agp.utils.TextAlignment;
import ohos.app.Context;

import com.prolificinteractive.materialcalendarview.format.WeekDayFormatter;

import org.threeten.bp.DayOfWeek;

/**
 * Display a day of the week
 */
class WeekDayView extends Text {

    private WeekDayFormatter formatter = WeekDayFormatter.DEFAULT;
    private DayOfWeek dayOfWeek;

    public WeekDayView(final Context context, final DayOfWeek dayOfWeek,Font font) {
        super(context);
        setTextAlignment(TextAlignment.TOP);
        setMultipleLine(true);
        setDayOfWeek(dayOfWeek);
        setMultipleLine(true);
        setTextColor(new Color(0xff808080));
        setTextSize(AttrHelper.fp2px(12, getContext()));
        if(font!=null){
            setFont(font);
            setTextColor(new Color(0xff000000));
            setTextSize(AttrHelper.fp2px(14, getContext()));
        }


    }

    public void setWeekDayFormatter(final WeekDayFormatter formatter) {
        this.formatter = formatter == null ? WeekDayFormatter.DEFAULT : formatter;
        setDayOfWeek(dayOfWeek);
    }

    public void setDayOfWeek(final DayOfWeek dayOfWeek) {
        this.dayOfWeek = dayOfWeek;
        setText(String.valueOf(formatter.format(dayOfWeek)));
    }
}
